<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>珠峰架构师成长计划</title>
    <link rel="stylesheet" type="text/css" href="../static/css/main.css">
</head>
<body>
<div class="nav">
    <div class="logo">
        
            珠峰架构师成长计划
        
    </div>
<ul><li><a href="../index.html">0.Async</a></li><li><a href="../html/0.editor.html">0.editor</a></li><li><a href="../html/0.module.html">0.module</a></li><li><a href="../html/1.ES2015.html">1.ES2015</a></li><li><a href="../html/2.Promise.html">2.Promise</a></li><li><a href="../html/3.Node.html">3.Node</a></li><li><a href="../html/4.NodeInstall.html">4.NodeInstall</a></li><li><a href="../html/5.REPL.html">5.REPL</a></li><li><a href="../html/6.NodeCore.html">6.NodeCore</a></li><li><a href="../html/7.module&NPM.html">7.module&NPM</a></li><li><a href="../html/8.Encoding.html">8.Encoding</a></li><li><a href="../html/9.Buffer.html">9.Buffer</a></li><li><a href="../html/10.fs.html">10.fs</a></li><li><a href="../html/11.Stream-1.html">11.Stream-1</a></li><li><a href="../html/11.Stream-2.html">11.Stream-2</a></li><li><a href="../html/11.Stream-3.html">11.Stream-3</a></li><li><a href="../html/11.Stream-4.html">11.Stream-4</a></li><li><a href="../html/12-Network-2.html">12-Network-2</a></li><li><a href="../html/12.NetWork-3.html">12.NetWork-3</a></li><li><a href="../html/12.Network-1.html">12.Network-1</a></li><li><a href="../html/13.tcp.html">13.tcp</a></li><li><a href="../html/14.http-1.html">14.http-1</a></li><li><a href="../html/14.http-2.html">14.http-2</a></li><li><a href="../html/15.compress.html">15.compress</a></li><li><a href="../html/16.crypto.html">16.crypto</a></li><li><a href="../html/17.process.html">17.process</a></li><li><a href="../html/18.yargs.html">18.yargs</a></li><li><a href="../html/19.cache.html">19.cache</a></li><li><a href="../html/20.action.html">20.action</a></li><li><a href="../html/21.https.html">21.https</a></li><li><a href="../html/22.cookie.html">22.cookie</a></li><li><a href="../html/23.session.html">23.session</a></li><li><a href="../html/24.express-1.html">24.express-1</a></li><li><a href="../html/24.express-2.html">24.express-2</a></li><li><a href="../html/24.express-3.html">24.express-3</a></li><li><a href="../html/24.express-4.html">24.express-4</a></li><li><a href="../html/25.koa-1.html">25.koa-1</a></li><li><a href="../html/26.webpack-1-basic.html">26.webpack-1-basic</a></li><li><a href="../html/26.webpack-2-optimize.html">26.webpack-2-optimize</a></li><li><a href="../html/26.webpack-3.tapable.html">26.webpack-3.tapable</a></li><li><a href="../html/26.webpack-4-AST.html">26.webpack-4-AST</a></li><li><a href="../html/26.webpack-5-source.html">26.webpack-5-source</a></li><li><a href="../html/26.webpack-6-loader.html">26.webpack-6-loader</a></li><li><a href="../html/26.webpack-7-plugin.html">26.webpack-7-plugin</a></li><li><a href="../html/26.webpack-8-hand.html">26.webpack-8-hand</a></li><li><a href="../html/27.react-1.html">27.react-1</a></li><li><a href="../html/27.react-2.html">27.react-2</a></li><li><a href="../html/27.react-3.html">27.react-3</a></li><li><a href="../html/27.react-4-immutable.html">27.react-4-immutable</a></li><li><a href="../html/27.react-5-react-dom-diff.html">27.react-5-react-dom-diff</a></li><li><a href="../html/27.react-6.html">27.react-6</a></li><li><a href="../html/28.react-mobx.html">28.react-mobx</a></li><li><a href="../html/28.redux-0.html">28.redux-0</a></li><li><a href="../html/28.redux-1.html">28.redux-1</a></li><li><a href="../html/28.redux-2-中间件.html">28.redux-2-中间件</a></li><li><a href="../html/28.redux-3-saga.html">28.redux-3-saga</a></li><li><a href="../html/28.redux-jwt-back.html">28.redux-jwt-back</a></li><li><a href="../html/28.redux-jwt-front.html">28.redux-jwt-front</a></li><li><a href="../html/29.mongodb-1.html">29.mongodb-1</a></li><li><a href="../html/29.mongodb-2.html">29.mongodb-2</a></li><li><a href="../html/29.mongodb-3.html">29.mongodb-3</a></li><li><a href="../html/29.mongodb-4.html">29.mongodb-4</a></li><li><a href="../html/29.mongodb-5.html">29.mongodb-5</a></li><li><a href="../html/29.mongodb-6.html">29.mongodb-6</a></li><li><a href="../html/30.cms-1-mysql.html">30.cms-1-mysql</a></li><li><a href="../html/30.cms-2-mysql.html">30.cms-2-mysql</a></li><li><a href="../html/30.cms-3-mysql.html">30.cms-3-mysql</a></li><li><a href="../html/30.cms-4-egg.html">30.cms-4-egg</a></li><li><a href="../html/30.cms-5-api.html">30.cms-5-api</a></li><li><a href="../html/30.cms-6-roadhog.html">30.cms-6-roadhog</a></li><li><a href="../html/30.cms-7-umi.html">30.cms-7-umi</a></li><li><a href="../html/30.cms-8-dva.html">30.cms-8-dva</a></li><li><a href="../html/30.cms-9-dva.html">30.cms-9-dva</a></li><li><a href="../html/30.cms-10-front.html">30.cms-10-front</a></li><li><a href="../html/30.cms-11-deploy.html">30.cms-11-deploy</a></li><li><a href="../html/33.redis.html">33.redis</a></li><li><a href="../html/34.unittest.html">34.unittest</a></li><li><a href="../html/35.jwt.html">35.jwt</a></li><li><a href="../html/36.websocket-1.html">36.websocket-1</a></li><li><a href="../html/36.websocket-2.html">36.websocket-2</a></li><li><a href="../html/38.chat-api-1.html">38.chat-api-1</a></li><li><a href="../html/38.chat-api-2.html">38.chat-api-2</a></li><li><a href="../html/38.chat-3.html">38.chat-3</a></li><li><a href="../html/38.chat-api-3.html">38.chat-api-3</a></li><li><a href="../html/38.chat.html">38.chat</a></li><li><a href="../html/38.chat2.html">38.chat2</a></li><li><a href="../html/38.chat2.html">38.chat2</a></li><li><a href="../html/39.crawl-0.html">39.crawl-0</a></li><li class="active"><a href="../html/39.crawl-1.html">39.crawl-1</a></li><li><a href="../html/39.crawl-2.html">39.crawl-2</a></li><li><a href="../html/40.deploy.html">40.deploy</a></li><li><a href="../html/41.safe.html">41.safe</a></li><li><a href="../html/42.test.html">42.test</a></li><li><a href="../html/43.nginx.html">43.nginx</a></li><li><a href="../html/44.enzyme.html">44.enzyme</a></li><li><a href="../html/45.docker.html">45.docker</a></li><li><a href="../html/46.elastic.html">46.elastic</a></li><li><a href="../html/47.oauth.html">47.oauth</a></li><li><a href="../html/48.wxpay.html">48.wxpay</a></li><li><a href="../html/49.nunjucks.html">49.nunjucks</a></li><li><a href="../html/50.ketang.html">50.ketang</a></li><li><a href="../html/index.html">index</a></li><li><a href="../html/51.typescript.html">51.typescript</a></li><li><a href="../html/52.UML.html">52.UML</a></li><li><a href="../html/53.design.html">53.design</a></li><li><a href="../html/index.html">index</a></li><li><a href="../html/54.linux.html">54.linux</a></li><li><a href="../html/55.yaml.html">55.yaml</a></li><li><a href="../html/50.ketang2.html">50.ketang2</a></li><li><a href="../html/56.ts.html">56.ts</a></li><li><a href="../html/57.ts_react.html">57.ts_react</a></li><li><a href="../html/58.react-ssr.html">58.react-ssr</a></li><li><a href="../html/59.react-ssr.html">59.react-ssr</a></li></ul></div>


<div class="warpper">

    <div class="page-toc">
        <ul><li><a href="#t01. 掘金爬虫">1. 掘金爬虫</a></li><li><a href="#t12. 核心步骤">2. 核心步骤</a></li><li><a href="#t23. 核心类库">3. 核心类库</a><ul><li><a href="#t33.1 request">3.1 request</a><ul><li><a href="#t43.1.1 安装">3.1.1 安装</a></li><li><a href="#t53.1.2 GET请求">3.1.2 GET请求</a></li><li><a href="#t63.1.3 POST application/json">3.1.3 POST application/json</a></li><li><a href="#t73.1.4 POST application/x-www-form-urlencoded">3.1.4 POST application/x-www-form-urlencoded</a></li><li><a href="#t83.1.5 POST multipart/form-data">3.1.5 POST multipart/form-data</a></li></ul></li><li><a href="#t93.2 cheerio">3.2 cheerio</a><ul><li><a href="#t103.2.1 安装">3.2.1 安装</a></li><li><a href="#t113.2.2 load装载DOM">3.2.2 load装载DOM</a></li><li><a href="#t123.2.3 选择器">3.2.3 选择器</a></li><li><a href="#t133.2.5 attr修改属性">3.2.5 attr修改属性</a></li><li><a href="#t143.2.6 removeAttr(name)">3.2.6 removeAttr(name)</a></li><li><a href="#t153.2.7 prop()修改状态值">3.2.7 prop()修改状态值</a></li><li><a href="#t163.2.8 data()自定义属性">3.2.8 data()自定义属性</a></li><li><a href="#t173.2.9 val()赋值">3.2.9 val()赋值</a></li><li><a href="#t183.2.10 hasClass( className )">3.2.10 hasClass( className )</a></li><li><a href="#t193.2.11 addClass(name)">3.2.11 addClass(name)</a></li><li><a href="#t203.2.12 emoveClass([className])">3.2.12 emoveClass([className])</a></li><li><a href="#t213.2.13 find(selector)">3.2.13 find(selector)</a></li><li><a href="#t223.2.14 parent([selector])">3.2.14 parent([selector])</a></li><li><a href="#t233.2.15 next()获得第一个本元素之后的同级元素">3.2.15 next()获得第一个本元素之后的同级元素</a></li><li><a href="#t243.2.16 .nextAll()">3.2.16 .nextAll()</a></li><li><a href="#t253.2.17 prev()">3.2.17 prev()</a></li><li><a href="#t263.2.18 preAll()">3.2.18 preAll()</a></li><li><a href="#t273.2.19 slice(start,[end])">3.2.19 slice(start,[end])</a></li><li><a href="#t283.2.20 siblings(selector)">3.2.20 siblings(selector)</a></li><li><a href="#t293.2.21 first()">3.2.21 first()</a></li><li><a href="#t303.2.22 last()">3.2.22 last()</a></li><li><a href="#t313.2.23 eq(i)">3.2.23 eq(i)</a></li><li><a href="#t323.2.24 children(selector)">3.2.24 children(selector)</a></li><li><a href="#t333.2.25 each(function(index,element))">3.2.25 each(function(index,element))</a></li><li><a href="#t343.2.26 map(function(index,element))">3.2.26 map(function(index,element))</a></li><li><a href="#t353.2.27 filter(selector)">3.2.27 filter(selector)</a></li><li><a href="#t363.2.28 append(content,[content…])">3.2.28 append(content,[content…])</a></li><li><a href="#t373.2.29 prepend(content,[content,…])">3.2.29 prepend(content,[content,…])</a></li><li><a href="#t383.2.30 after(content,[content,…])">3.2.30 after(content,[content,…])</a></li><li><a href="#t393.2.31 before(content,[content,…])">3.2.31 before(content,[content,…])</a></li><li><a href="#t403.2.32 remove( [selector] )">3.2.32 remove( [selector] )</a></li><li><a href="#t413.2.33 replaceWith( content )">3.2.33 replaceWith( content )</a></li><li><a href="#t423.2.34 empty()">3.2.34 empty()</a></li><li><a href="#t433.2.35 html( [htmlString] )">3.2.35 html( [htmlString] )</a></li><li><a href="#t443.2.36 text( [textString] )">3.2.36 text( [textString] )</a></li></ul></li><li><a href="#t453.3 debug">3.3 debug</a></li><li><a href="#t463.4 corn">3.4 corn</a></li><li><a href="#t473.5 监听未知错误">3.5 监听未知错误</a></li><li><a href="#t483.6 pm2">3.6 pm2</a></li><li><a href="#t493.7 编码(iconv-lite)">3.7 编码(iconv-lite)</a></li><li><a href="#t503.8 发送邮件">3.8 发送邮件</a></li></ul></li><li><a href="#t513.9 HTTP代理工具">3.9 HTTP代理工具</a><ul><li><a href="#t523.9.1 https抓包设置">3.9.1 https抓包设置</a><ul><li><a href="#t533.9.1.1 Fiddler">3.9.1.1 Fiddler</a></li><li><a href="#t543.9.1.2 Android">3.9.1.2 Android</a></li><li><a href="#t553.9.1.3 抓取接口">3.9.1.3 抓取接口</a></li></ul></li></ul></li><li><a href="#t56参考">参考</a></li></ul>
    </div>
    
    <div class="content markdown-body">
        <h2 id="t01. &#x6398;&#x91D1;&#x722C;&#x866B;">1. &#x6398;&#x91D1;&#x722C;&#x866B; <a href="#t01. &#x6398;&#x91D1;&#x722C;&#x866B;"> # </a></h2>
<p>&#x901A;&#x8FC7;&#x4E00;&#x4E2A;&#x5B9E;&#x4F8B;&#x6765;&#x4ECB;&#x7ECD;&#x5982;&#x4F55;&#x7F16;&#x5199;&#x7F51;&#x7EDC;&#x722C;&#x866B;&#x6293;&#x53BB;&#x6398;&#x91D1;&#x6570;&#x636E;&#xFF0C;&#x5E76;&#x5B58;&#x50A8;&#x5230;MySQL&#x6570;&#x636E;&#x5E93;&#x4E2D;&#xFF0C;&#x4EE5;&#x53CA;&#x5B9A;&#x65F6;&#x4EFB;&#x52A1;&#x722C;&#x866B;&#x6765;&#x66F4;&#x65B0;&#x5185;&#x5BB9;</p>
<h2 id="t12. &#x6838;&#x5FC3;&#x6B65;&#x9AA4;">2. &#x6838;&#x5FC3;&#x6B65;&#x9AA4; <a href="#t12. &#x6838;&#x5FC3;&#x6B65;&#x9AA4;"> # </a></h2>
<ol>
<li>&#x53D1;&#x8D77;HTTP&#x8BF7;&#x6C42;&#x83B7;&#x53D6;&#x7F51;&#x9875;&#x5185;&#x5BB9;</li>
<li>&#x4F7F;&#x7528;&#x7C7B;&#x4F3C;jQuery&#x7684;&#x8BED;&#x6CD5;&#x6765;&#x64CD;&#x4F5C;&#x7F51;&#x9875;&#x63D0;&#x53D6;&#x9700;&#x8981;&#x7684;&#x6570;&#x636E;</li>
<li>&#x628A;&#x6570;&#x636E;&#x4FDD;&#x5B58;&#x5230;&#x6570;&#x636E;&#x5E93;&#x4E2D;&#x4EE5;&#x4F9B;&#x67E5;&#x8BE2;</li>
<li>&#x5EFA;&#x7ACB;&#x4E00;&#x4E2A;&#x670D;&#x52A1;&#x5668;&#x6765;&#x663E;&#x793A;&#x8FD9;&#x4E9B;&#x6570;&#x636E;</li>
<li>&#x53EF;&#x4EE5;&#x5B9A;&#x65F6;&#x722C;&#x53D6;&#x6570;&#x636E;</li>
<li>&#x8BA9;&#x7A0B;&#x5E8F;&#x7A33;&#x5B9A;&#x8FD0;&#x884C;</li>
<li>&#x5BF9;&#x7F16;&#x7801;&#x8FDB;&#x884C;&#x8F6C;&#x6362;</li>
</ol>
<h2 id="t23. &#x6838;&#x5FC3;&#x7C7B;&#x5E93;">3. &#x6838;&#x5FC3;&#x7C7B;&#x5E93; <a href="#t23. &#x6838;&#x5FC3;&#x7C7B;&#x5E93;"> # </a></h2>
<h3 id="t33.1 request">3.1 request <a href="#t33.1 request"> # </a></h3>
<ul>
<li><a href="https://nodei.co/npm/request">npm request</a></li>
<li><a href="https://github.com/request/request">github request</a></li>
</ul>
<h4 id="t43.1.1 &#x5B89;&#x88C5;">3.1.1 &#x5B89;&#x88C5; <a href="#t43.1.1 &#x5B89;&#x88C5;"> # </a></h4>
<pre><code class="lang-js">npm install --save request
</code></pre>
<h4 id="t53.1.2 GET&#x8BF7;&#x6C42;">3.1.2 GET&#x8BF7;&#x6C42; <a href="#t53.1.2 GET&#x8BF7;&#x6C42;"> # </a></h4>
<pre><code class="lang-js"><span class="hljs-keyword">var</span> request = <span class="hljs-built_in">require</span>(<span class="hljs-string">&apos;request&apos;</span>);
request(<span class="hljs-string">&apos;http://www.baidu.com&apos;</span>, <span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params">error, response, body</span>) </span>{
  <span class="hljs-keyword">if</span> (!error &amp;&amp; response.statusCode == <span class="hljs-number">200</span>) {
    <span class="hljs-built_in">console</span>.log(body);
  }
</code></pre>
<h4 id="t63.1.3 POST application/json">3.1.3 POST application/json <a href="#t63.1.3 POST application/json"> # </a></h4>
<pre><code class="lang-js"><span class="hljs-keyword">const</span> request=<span class="hljs-built_in">require</span>(<span class="hljs-string">&apos;request&apos;</span>);
<span class="hljs-keyword">const</span> options={
    <span class="hljs-attr">url</span>: <span class="hljs-string">&apos;http://localhost:8080/post&apos;</span>,
    <span class="hljs-attr">method</span>:<span class="hljs-string">&apos;POST&apos;</span>,
    <span class="hljs-attr">json</span>: <span class="hljs-literal">true</span>,
    <span class="hljs-attr">headers</span>: {
        <span class="hljs-string">&quot;Content-Type&quot;</span>:<span class="hljs-string">&quot;application/json&quot;</span>
    },
    <span class="hljs-attr">body</span>: {<span class="hljs-attr">name</span>:<span class="hljs-string">&quot;zfpx&quot;</span>,<span class="hljs-attr">age</span>:<span class="hljs-number">8</span>}
}
request(options,<span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params">error,response,body</span>) </span>{
    <span class="hljs-keyword">if</span> (!error &amp;&amp; response.statusCode == <span class="hljs-number">200</span>) {
        <span class="hljs-built_in">console</span>.log(body);
    } <span class="hljs-keyword">else</span> {
        <span class="hljs-built_in">console</span>.error(error);
    }
});
</code></pre>
<h4 id="t73.1.4 POST application/x-www-form-urlencoded">3.1.4 POST application/x-www-form-urlencoded <a href="#t73.1.4 POST application/x-www-form-urlencoded"> # </a></h4>
<pre><code class="lang-js"><span class="hljs-keyword">const</span> request=<span class="hljs-built_in">require</span>(<span class="hljs-string">&apos;request&apos;</span>);
<span class="hljs-keyword">const</span> options={
    <span class="hljs-attr">url</span>: <span class="hljs-string">&apos;http://localhost:8080/form&apos;</span>,
    <span class="hljs-attr">method</span>:<span class="hljs-string">&apos;POST&apos;</span>,
    <span class="hljs-attr">json</span>: <span class="hljs-literal">true</span>,
    <span class="hljs-attr">form</span>:{<span class="hljs-attr">name</span>:<span class="hljs-string">&apos;zfpx&apos;</span>,<span class="hljs-attr">age</span>:<span class="hljs-number">10</span>}
}
request(options,<span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params">error,response,body</span>) </span>{
    <span class="hljs-keyword">if</span> (!error &amp;&amp; response.statusCode == <span class="hljs-number">200</span>) {
        <span class="hljs-built_in">console</span>.log(body);
    } <span class="hljs-keyword">else</span> {
        <span class="hljs-built_in">console</span>.error(error);
    }
});
</code></pre>
<h4 id="t83.1.5 POST multipart/form-data">3.1.5 POST multipart/form-data <a href="#t83.1.5 POST multipart/form-data"> # </a></h4>
<pre><code class="lang-js"><span class="hljs-keyword">const</span> request=<span class="hljs-built_in">require</span>(<span class="hljs-string">&apos;request&apos;</span>);
<span class="hljs-keyword">const</span> fs=<span class="hljs-built_in">require</span>(<span class="hljs-string">&apos;fs&apos;</span>);
<span class="hljs-keyword">var</span> formData = {
    <span class="hljs-attr">name</span>: <span class="hljs-string">&apos;zfpx&apos;</span>,
    <span class="hljs-attr">avatar</span>:{
      <span class="hljs-attr">value</span>:  fs.createReadStream(<span class="hljs-string">&apos;avatar.jpg&apos;</span>),
      <span class="hljs-attr">options</span>: {
        <span class="hljs-attr">filename</span>: <span class="hljs-string">&apos;avatar.jpg&apos;</span>,
        <span class="hljs-attr">contentType</span>: <span class="hljs-string">&apos;image/jpeg&apos;</span>
      }
  }
};
request.post({<span class="hljs-attr">url</span>:<span class="hljs-string">&apos;http://localhost:8080/upload&apos;</span>, formData}, <span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params">error, response, body</span>) </span>{  
    <span class="hljs-keyword">if</span> (!error&amp;&amp;response.statusCode==<span class="hljs-number">200</span>) {
        <span class="hljs-built_in">console</span>.log(body);
    } <span class="hljs-keyword">else</span> {
        <span class="hljs-built_in">console</span>.log(error);
    }
})
</code></pre>
<h3 id="t93.2 cheerio">3.2 cheerio <a href="#t93.2 cheerio"> # </a></h3>
<p><a href="https://www.npmjs.com/package/cheerio">cheerio</a>&#x662F;&#x4E00;&#x4E2A;node&#x7684;&#x5E93;&#xFF0C;&#x53EF;&#x4EE5;&#x7406;&#x89E3;&#x4E3A;&#x4E00;&#x4E2A;Node.js&#x7248;&#x672C;&#x7684;jquery&#xFF0C;&#x4F7F;&#x7528;&#x65B9;&#x5F0F;&#x548C;jquery&#x57FA;&#x672C;&#x76F8;&#x540C;&#x3002;</p>
<h4 id="t103.2.1 &#x5B89;&#x88C5;">3.2.1 &#x5B89;&#x88C5; <a href="#t103.2.1 &#x5B89;&#x88C5;"> # </a></h4>
<pre><code class="lang-js">npm install cheerio
</code></pre>
<h4 id="t113.2.2 load&#x88C5;&#x8F7D;DOM">3.2.2 load&#x88C5;&#x8F7D;DOM <a href="#t113.2.2 load&#x88C5;&#x8F7D;DOM"> # </a></h4>
<pre><code class="lang-js"><span class="hljs-keyword">let</span> str=<span class="hljs-string">`
&lt;h2 class=&quot;title&quot;&gt;Hello world&lt;/h2&gt;
`</span>;
<span class="hljs-keyword">const</span> cheerio=<span class="hljs-built_in">require</span>(<span class="hljs-string">&apos;cheerio&apos;</span>);
<span class="hljs-keyword">const</span> $=cheerio.load(str);
$(<span class="hljs-string">&apos;h2.title&apos;</span>).text(<span class="hljs-string">&apos;hello there!&apos;</span>);
$(<span class="hljs-string">&apos;h2&apos;</span>).addClass(<span class="hljs-string">&apos;welcome&apos;</span>);
<span class="hljs-built_in">console</span>.log($.html());
</code></pre>
<h4 id="t123.2.3 &#x9009;&#x62E9;&#x5668;">3.2.3 &#x9009;&#x62E9;&#x5668; <a href="#t123.2.3 &#x9009;&#x62E9;&#x5668;"> # </a></h4>
<ul>
<li>&#x9009;&#x62E9;&#x5668;&#x5728; Context &#x8303;&#x56F4;&#x5185;&#x641C;&#x7D22;&#xFF0C;Context&#x53C8;&#x5728;Root&#x8303;&#x56F4;&#x5185;&#x641C;&#x7D22;&#x3002;</li>
<li>root&#x5728;&#x53F3;&#xFF0C;context&#x5728;&#x5DE6;</li>
<li>selector &#x548C;context&#x53EF;&#x4EE5;&#x662F;&#x4E00;&#x4E2A;&#x5B57;&#x7B26;&#x4E32;&#x8868;&#x8FBE;&#x5F0F;&#xFF0C;DOM&#x5143;&#x7D20;&#xFF0C;&#x548C;DOM&#x5143;&#x7D20;&#x7684;&#x6570;&#x7EC4;&#xFF0C;&#x6216;&#x8005;chreeio&#x5BF9;&#x8C61;&#x3002;</li>
<li>root &#x662F;&#x901A;&#x5E38;&#x662F;HTML &#x6587;&#x6863;&#x5B57;&#x7B26;&#x4E32;&#x3002;</li>
</ul>
<pre><code class="lang-js">$(selectior,[context],[root])
</code></pre>
<pre><code class="lang-js"><span class="hljs-keyword">let</span> html=<span class="hljs-string">`
&lt;ul id=&quot;fruits&quot;&gt;
  &lt;li class=&quot;apple&quot;&gt;Apple&lt;/li&gt;
  &lt;li class=&quot;orange&quot;&gt;Orange&lt;/li&gt;
  &lt;li class=&quot;pear&quot;&gt;Pear&lt;/li&gt;
&lt;/ul&gt;
`</span>;

<span class="hljs-keyword">let</span> cheerio=<span class="hljs-built_in">require</span>(<span class="hljs-string">&apos;cheerio&apos;</span>);
<span class="hljs-keyword">let</span> $=cheerio.load(html);
<span class="hljs-built_in">console</span>.log($(<span class="hljs-string">&apos;.apple&apos;</span>,<span class="hljs-string">&apos;#fruits&apos;</span>).text());
</code></pre>
<h4 id="t133.2.5 attr&#x4FEE;&#x6539;&#x5C5E;&#x6027;">3.2.5 attr&#x4FEE;&#x6539;&#x5C5E;&#x6027; <a href="#t133.2.5 attr&#x4FEE;&#x6539;&#x5C5E;&#x6027;"> # </a></h4>
<ul>
<li>&#x83B7;&#x5F97;&#x548C;&#x4FEE;&#x6539;&#x5C5E;&#x6027;</li>
<li>&#x5728;&#x5339;&#x914D;&#x7684;&#x5143;&#x7D20;&#x4E2D;&#x53EA;&#x80FD;&#x83B7;&#x5F97;&#x7B2C;&#x4E00;&#x5143;&#x7D20;&#x7684;&#x5C5E;&#x6027;&#x3002;</li>
<li>&#x5982;&#x679C;&#x8BBE;&#x7F6E;&#x4E00;&#x4E2A;&#x5C5E;&#x6027;&#x7684;&#x503C;&#x4E3A;null&#xFF0C;&#x5219;&#x79FB;&#x9664;&#x8FD9;&#x4E2A;&#x5C5E;&#x6027;</li>
<li>&#x4F60;&#x4E5F;&#x53EF;&#x4EE5;&#x4F20;&#x9012;&#x4E00;&#x5BF9;&#x952E;&#x503C;&#xFF0C;&#x6216;&#x8005;&#x4E00;&#x4E2A;&#x51FD;&#x6570;&#x3002;<pre><code class="lang-js">attr(name,value)
</code></pre>
</li>
</ul>
<pre><code class="lang-js"><span class="hljs-built_in">console</span>.log($(<span class="hljs-string">&apos;ul&apos;</span>).attr(<span class="hljs-string">&apos;id&apos;</span>));
$(<span class="hljs-string">&apos;.apple&apos;</span>).attr(<span class="hljs-string">&apos;id&apos;</span>,<span class="hljs-string">&apos;favorite&apos;</span>).attr(<span class="hljs-string">&apos;class&apos;</span>,<span class="hljs-string">&apos;favorite&apos;</span>);
$(<span class="hljs-string">&apos;.apple&apos;</span>).attr({<span class="hljs-attr">id</span>:<span class="hljs-string">&apos;favorite&apos;</span>,<span class="hljs-attr">class</span>:<span class="hljs-string">&apos;favorite&apos;</span>});
<span class="hljs-built_in">console</span>.log($(<span class="hljs-string">&apos;.favorite&apos;</span>).html());
<span class="hljs-built_in">console</span>.log($(<span class="hljs-string">&apos;ul&apos;</span>).html());
</code></pre>
<h4 id="t143.2.6 removeAttr(name)">3.2.6 removeAttr(name) <a href="#t143.2.6 removeAttr(name)"> # </a></h4>
<p>&#x901A;&#x8FC7;name&#x5220;&#x9664;&#x5C5E;&#x6027;</p>
<pre><code class="lang-js">$(<span class="hljs-string">&apos;.favorite&apos;</span>).removeAttr(<span class="hljs-string">&apos;id&apos;</span>);
</code></pre>
<h4 id="t153.2.7 prop()&#x4FEE;&#x6539;&#x72B6;&#x6001;&#x503C;">3.2.7 prop()&#x4FEE;&#x6539;&#x72B6;&#x6001;&#x503C; <a href="#t153.2.7 prop()&#x4FEE;&#x6539;&#x72B6;&#x6001;&#x503C;"> # </a></h4>
<pre><code class="lang-js">$(<span class="hljs-string">&apos;input[type=&quot;checkbox&quot;]&apos;</span>).prop(<span class="hljs-string">&apos;checked&apos;</span>)
<span class="hljs-comment">//=&gt; false</span>

$(<span class="hljs-string">&apos;input[type=&quot;checkbox&quot;]&apos;</span>).prop(<span class="hljs-string">&apos;checked&apos;</span>, <span class="hljs-literal">true</span>).val()
<span class="hljs-comment">//=&gt; ok</span>
</code></pre>
<h4 id="t163.2.8 data()&#x81EA;&#x5B9A;&#x4E49;&#x5C5E;&#x6027;">3.2.8 data()&#x81EA;&#x5B9A;&#x4E49;&#x5C5E;&#x6027; <a href="#t163.2.8 data()&#x81EA;&#x5B9A;&#x4E49;&#x5C5E;&#x6027;"> # </a></h4>
<pre><code class="lang-js">$(<span class="hljs-string">&apos;&lt;div data-apple-color=&quot;red&quot;&gt;&lt;/div&gt;&apos;</span>).data()
<span class="hljs-comment">//=&gt; { appleColor: &apos;red&apos; }</span>

$(<span class="hljs-string">&apos;&lt;div data-apple-color=&quot;red&quot;&gt;&lt;/div&gt;&apos;</span>).data(<span class="hljs-string">&apos;apple-color&apos;</span>)
<span class="hljs-comment">//=&gt; &apos;red&apos;</span>

<span class="hljs-keyword">var</span> apple = $(<span class="hljs-string">&apos;.apple&apos;</span>).data(<span class="hljs-string">&apos;kind&apos;</span>, <span class="hljs-string">&apos;mac&apos;</span>)
apple.data(<span class="hljs-string">&apos;kind&apos;</span>)
<span class="hljs-comment">//=&gt; &apos;mac&apos;</span>
</code></pre>
<h4 id="t173.2.9 val()&#x8D4B;&#x503C;">3.2.9 val()&#x8D4B;&#x503C; <a href="#t173.2.9 val()&#x8D4B;&#x503C;"> # </a></h4>
<pre><code class="lang-js">$(<span class="hljs-string">&apos;input[type=&quot;text&quot;]&apos;</span>).val()
<span class="hljs-comment">//=&gt; input_text</span>

$(<span class="hljs-string">&apos;input[type=&quot;text&quot;]&apos;</span>).val(<span class="hljs-string">&apos;test&apos;</span>).html()
<span class="hljs-comment">//=&gt; &lt;input type=&quot;text&quot; value=&quot;test&quot;/&gt;</span>
</code></pre>
<h4 id="t183.2.10 hasClass( className )">3.2.10 hasClass( className ) <a href="#t183.2.10 hasClass( className )"> # </a></h4>
<p>&#x68C0;&#x67E5;&#x5339;&#x914D;&#x7684;&#x5143;&#x7D20;&#x662F;&#x5426;&#x6709;&#x7ED9;&#x51FA;&#x7684;&#x7C7B;&#x540D;</p>
<pre><code class="lang-js">$(<span class="hljs-string">&apos;.pear&apos;</span>).hasClass(<span class="hljs-string">&apos;pear&apos;</span>)<span class="hljs-comment">//=&gt; true</span>
$(<span class="hljs-string">&apos;apple&apos;</span>).hasClass(<span class="hljs-string">&apos;fruit&apos;</span>)<span class="hljs-comment">//=&gt; false</span>
$(<span class="hljs-string">&apos;li&apos;</span>).hasClass(<span class="hljs-string">&apos;pear&apos;</span>)<span class="hljs-comment">//=&gt; true</span>
</code></pre>
<h4 id="t193.2.11 addClass(name)">3.2.11 addClass(name) <a href="#t193.2.11 addClass(name)"> # </a></h4>
<p>&#x589E;&#x52A0;class(es)&#x7ED9;&#x6240;&#x6709;&#x5339;&#x914D;&#x7684;elements.&#x4E5F;&#x53EF;&#x4EE5;&#x4F20;&#x51FD;&#x6570;&#x3002;</p>
<pre><code class="lang-js">$(<span class="hljs-string">&apos;.pear&apos;</span>).addClass(<span class="hljs-string">&apos;fruit&apos;</span>).html()<span class="hljs-comment">//=&gt; &lt;li class=&quot;pear fruit&quot;&gt;Pear&lt;/li&gt;</span>
$(<span class="hljs-string">&apos;.apple&apos;</span>).addClass(<span class="hljs-string">&apos;fruit red&apos;</span>).html()<span class="hljs-comment">//=&gt; &lt;li class=&quot;apple fruit red&quot;&gt;Apple&lt;/li&gt;</span>
</code></pre>
<h4 id="t203.2.12 emoveClass([className])">3.2.12 emoveClass([className]) <a href="#t203.2.12 emoveClass([className])"> # </a></h4>
<p>&#x4ECE;&#x9009;&#x62E9;&#x7684;elements&#x91CC;&#x53BB;&#x9664;&#x4E00;&#x4E2A;&#x6216;&#x591A;&#x4E2A;&#x6709;&#x7A7A;&#x683C;&#x5206;&#x5F00;&#x7684;class&#x3002;&#x5982;&#x679C;className &#x6CA1;&#x6709;&#x5B9A;&#x4E49;&#xFF0C;&#x6240;&#x6709;&#x7684;classes&#x5C06;&#x4F1A;&#x88AB;&#x53BB;&#x9664;&#xFF0C;&#x4E5F;&#x53EF;&#x4EE5;&#x4F20;&#x51FD;&#x6570;</p>
<pre><code class="lang-js">$(<span class="hljs-string">&apos;.pear&apos;</span>).removeClass(<span class="hljs-string">&apos;pear&apos;</span>).html()<span class="hljs-comment">//=&gt;Pear</span>
$(<span class="hljs-string">&apos;.apple&apos;</span>).addClass(<span class="hljs-string">&apos;red&apos;</span>).removeClass().html()<span class="hljs-comment">//=&gt;Apple</span>
</code></pre>
<h4 id="t213.2.13 find(selector)">3.2.13 find(selector) <a href="#t213.2.13 find(selector)"> # </a></h4>
<p>&#x83B7;&#x5F97;&#x4E00;&#x4E2A;&#x5728;&#x5339;&#x914D;&#x7684;&#x5143;&#x7D20;&#x4E2D;&#x7531;&#x9009;&#x62E9;&#x5668;&#x6EE4;&#x8FC7;&#x7684;&#x540E;&#x4EE3;</p>
<pre><code class="lang-js">$(<span class="hljs-string">&apos;#fruits&apos;</span>).find(<span class="hljs-string">&apos;li&apos;</span>).length<span class="hljs-comment">//=&gt; 3</span>
</code></pre>
<h4 id="t223.2.14 parent([selector])">3.2.14 parent([selector]) <a href="#t223.2.14 parent([selector])"> # </a></h4>
<p>&#x83B7;&#x5F97;&#x901A;&#x8FC7;&#x9009;&#x62E9;&#x5668;&#x7B5B;&#x9009;&#x5339;&#x914D;&#x7684;&#x5143;&#x7D20;&#x7684;parent&#x96C6;&#x5408;</p>
<pre><code class="lang-js">$(<span class="hljs-string">&apos;.orange&apos;</span>).parents().length<span class="hljs-comment">// =&gt; 2</span>
$(<span class="hljs-string">&apos;.orange&apos;</span>).parents(<span class="hljs-string">&apos;#fruits&apos;</span>).length<span class="hljs-comment">// =&gt; 1</span>
</code></pre>
<h4 id="t233.2.15 next()&#x83B7;&#x5F97;&#x7B2C;&#x4E00;&#x4E2A;&#x672C;&#x5143;&#x7D20;&#x4E4B;&#x540E;&#x7684;&#x540C;&#x7EA7;&#x5143;&#x7D20;">3.2.15 next()&#x83B7;&#x5F97;&#x7B2C;&#x4E00;&#x4E2A;&#x672C;&#x5143;&#x7D20;&#x4E4B;&#x540E;&#x7684;&#x540C;&#x7EA7;&#x5143;&#x7D20; <a href="#t233.2.15 next()&#x83B7;&#x5F97;&#x7B2C;&#x4E00;&#x4E2A;&#x672C;&#x5143;&#x7D20;&#x4E4B;&#x540E;&#x7684;&#x540C;&#x7EA7;&#x5143;&#x7D20;"> # </a></h4>
<pre><code class="lang-js">$(<span class="hljs-string">&apos;.apple&apos;</span>).next().hasClass(<span class="hljs-string">&apos;orange&apos;</span>)<span class="hljs-comment">//=&gt; true</span>
$(<span class="hljs-string">&apos;.pear&apos;</span>).next().html()<span class="hljs-comment">//=&gt; null</span>
</code></pre>
<h4 id="t243.2.16 .nextAll()">3.2.16 .nextAll() <a href="#t243.2.16 .nextAll()"> # </a></h4>
<p>&#x83B7;&#x5F97;&#x672C;&#x5143;&#x7D20;&#x4E4B;&#x540E;&#x7684;&#x6240;&#x6709;&#x540C;&#x7EA7;&#x5143;&#x7D20;</p>
<pre><code class="lang-js">$(<span class="hljs-string">&apos;.apple&apos;</span>).nextAll()<span class="hljs-comment">//=&gt; [&lt;li class=&quot;orange&quot;&gt;Orange&lt;/li&gt;, &lt;li class=&quot;pear&quot;&gt;Pear&lt;/li&gt;]</span>
$(<span class="hljs-string">&apos;.apple&apos;</span>).nextAll().length<span class="hljs-comment">//=&gt;2</span>
</code></pre>
<h4 id="t253.2.17 prev()">3.2.17 prev() <a href="#t253.2.17 prev()"> # </a></h4>
<p>&#x83B7;&#x5F97;&#x672C;&#x5143;&#x7D20;&#x4E4B;&#x524D;&#x7684;&#x7B2C;&#x4E00;&#x4E2A;&#x540C;&#x7EA7;&#x5143;&#x7D20;</p>
<pre><code class="lang-js">$(<span class="hljs-string">&apos;.orange&apos;</span>).prev().hasClass(<span class="hljs-string">&apos;apple&apos;</span>)<span class="hljs-comment">//=&gt; true</span>
</code></pre>
<h4 id="t263.2.18 preAll()">3.2.18 preAll() <a href="#t263.2.18 preAll()"> # </a></h4>
<p>&#x83B7;&#x5F97;&#x672C;&#x5143;&#x7D20;&#x524D;&#x7684;&#x6240;&#x6709;&#x540C;&#x7EA7;&#x5143;&#x7D20;</p>
<pre><code class="lang-js">$(<span class="hljs-string">&apos;.pear&apos;</span>).prevAll()<span class="hljs-comment">//=&gt; [&lt;li class=&quot;orange&quot;&gt;Orange&lt;/li&gt;, &lt;li class=&quot;apple&quot;&gt;Apple&lt;/li&gt;]</span>
</code></pre>
<h4 id="t273.2.19 slice(start,[end])">3.2.19 slice(start,[end]) <a href="#t273.2.19 slice(start,[end])"> # </a></h4>
<p>&#x83B7;&#x5F97;&#x9009;&#x5B9A;&#x8303;&#x56F4;&#x5185;&#x7684;&#x5143;&#x7D20;&#x6570;&#x7EC4;</p>
<pre><code class="lang-js">$(<span class="hljs-string">&apos;li&apos;</span>).slice(<span class="hljs-number">1</span>).eq(<span class="hljs-number">0</span>).text()<span class="hljs-comment">//=&gt; &apos;Orange&apos;</span>
$(<span class="hljs-string">&apos;li&apos;</span>).slice(<span class="hljs-number">1</span>, <span class="hljs-number">2</span>).length<span class="hljs-comment">//=&gt; 1</span>
</code></pre>
<h4 id="t283.2.20 siblings(selector)">3.2.20 siblings(selector) <a href="#t283.2.20 siblings(selector)"> # </a></h4>
<p>&#x83B7;&#x5F97;&#x88AB;&#x9009;&#x62E9;&#x7684;&#x540C;&#x7EA7;&#x5143;&#x7D20;(&#x9664;&#x53BB;&#x81EA;&#x5DF1;)</p>
<pre><code class="lang-js">$(<span class="hljs-string">&apos;.pear&apos;</span>).siblings().length<span class="hljs-comment">//=&gt; 2</span>
$(<span class="hljs-string">&apos;.pear&apos;</span>).siblings(<span class="hljs-string">&apos;.orange&apos;</span>).length<span class="hljs-comment">//=&gt; 1</span>
$(<span class="hljs-string">&apos;.pear&apos;</span>).siblings(<span class="hljs-string">&apos;.pear&apos;</span>).length<span class="hljs-comment">//=&gt; 0</span>
</code></pre>
<h4 id="t293.2.21 first()">3.2.21 first() <a href="#t293.2.21 first()"> # </a></h4>
<p>&#x4F1A;&#x9009;&#x62E9;chreeio&#x5BF9;&#x8C61;&#x7684;&#x7B2C;&#x4E00;&#x4E2A;&#x5143;&#x7D20;</p>
<pre><code class="lang-js">(<span class="hljs-string">&apos;#fruits&apos;</span>).children().first().text()<span class="hljs-comment">//=&gt; Apple</span>
</code></pre>
<h4 id="t303.2.22 last()">3.2.22 last() <a href="#t303.2.22 last()"> # </a></h4>
<p>&#x4F1A;&#x9009;&#x62E9;chreeio&#x5BF9;&#x8C61;&#x7684;&#x6700;&#x540E;&#x4E00;&#x4E2A;&#x5143;&#x7D20;</p>
<pre><code class="lang-js">$(<span class="hljs-string">&apos;#fruits&apos;</span>).children().last().text()<span class="hljs-comment">//=&gt; Pear</span>
</code></pre>
<h4 id="t313.2.23 eq(i)">3.2.23 eq(i) <a href="#t313.2.23 eq(i)"> # </a></h4>
<p>&#x901A;&#x8FC7;&#x7D22;&#x5F15;&#x7B5B;&#x9009;&#x5339;&#x914D;&#x7684;&#x5143;&#x7D20;&#x3002;&#x4F7F;&#x7528;.eq(-i)&#x5C31;&#x4ECE;&#x6700;&#x540E;&#x4E00;&#x4E2A;&#x5143;&#x7D20;&#x5411;&#x524D;&#x6570;&#x3002;</p>
<pre><code class="lang-js">$(<span class="hljs-string">&apos;li&apos;</span>).eq(<span class="hljs-number">0</span>).text()<span class="hljs-comment">//=&gt; Apple</span>
$(<span class="hljs-string">&apos;li&apos;</span>).eq(<span class="hljs-number">-1</span>).text()<span class="hljs-comment">//=&gt; Pear</span>
</code></pre>
<h4 id="t323.2.24 children(selector)">3.2.24 children(selector) <a href="#t323.2.24 children(selector)"> # </a></h4>
<p>&#x83B7;&#x88AB;&#x9009;&#x62E9;&#x5143;&#x7D20;&#x7684;&#x5B50;&#x5143;&#x7D20;</p>
<pre><code class="lang-js">$(<span class="hljs-string">&apos;#fruits&apos;</span>).children().length<span class="hljs-comment">//=&gt; 3</span>
$(<span class="hljs-string">&apos;#fruits&apos;</span>).children(<span class="hljs-string">&apos;.pear&apos;</span>).text()<span class="hljs-comment">//=&gt; Pear</span>
</code></pre>
<h4 id="t333.2.25 each(function(index,element))">3.2.25 each(function(index,element)) <a href="#t333.2.25 each(function(index,element))"> # </a></h4>
<p>&#x8FED;&#x4EE3;&#x4E00;&#x4E2A;cheerio&#x5BF9;&#x8C61;&#xFF0C;&#x4E3A;&#x6BCF;&#x4E2A;&#x5339;&#x914D;&#x5143;&#x7D20;&#x6267;&#x884C;&#x4E00;&#x4E2A;&#x51FD;&#x6570;&#x3002;&#x8981;&#x63D0;&#x65E9;&#x8DF3;&#x51FA;&#x5FAA;&#x73AF;&#xFF0C;&#x8FD4;&#x56DE;false.</p>
<pre><code class="lang-js"><span class="hljs-keyword">var</span> fruits = [];

$(<span class="hljs-string">&apos;li&apos;</span>).each(<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">i, elem</span>) </span>{
  fruits[i] = $(<span class="hljs-keyword">this</span>).text();
});

fruits.join(<span class="hljs-string">&apos;, &apos;</span>);
<span class="hljs-comment">//=&gt; Apple, Orange, Pear</span>
</code></pre>
<h4 id="t343.2.26 map(function(index,element))">3.2.26 map(function(index,element)) <a href="#t343.2.26 map(function(index,element))"> # </a></h4>
<p>&#x8FED;&#x4EE3;&#x4E00;&#x4E2A;cheerio&#x5BF9;&#x8C61;&#xFF0C;&#x4E3A;&#x6BCF;&#x4E2A;&#x5339;&#x914D;&#x5143;&#x7D20;&#x6267;&#x884C;&#x4E00;&#x4E2A;&#x51FD;&#x6570;&#x3002;Map&#x4F1A;&#x8FD4;&#x56DE;&#x4E00;&#x4E2A;&#x8FED;&#x4EE3;&#x7ED3;&#x679C;&#x7684;&#x6570;&#x7EC4;&#x3002;</p>
<pre><code class="lang-js">$(<span class="hljs-string">&apos;li&apos;</span>).map(<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">i, el</span>) </span>{ 
  <span class="hljs-keyword">return</span> $(<span class="hljs-keyword">this</span>).attr(<span class="hljs-string">&apos;class&apos;</span>);
}).join(<span class="hljs-string">&apos;, &apos;</span>);
<span class="hljs-comment">//=&gt; apple, orange, pear</span>
</code></pre>
<h4 id="t353.2.27 filter(selector)">3.2.27 filter(selector) <a href="#t353.2.27 filter(selector)"> # </a></h4>
<ul>
<li>&#x8FED;&#x4EE3;&#x4E00;&#x4E2A;cheerio&#x5BF9;&#x8C61;&#xFF0C;&#x6EE4;&#x51FA;&#x5339;&#x914D;&#x9009;&#x62E9;&#x5668;&#x6216;&#x8005;&#x662F;&#x4F20;&#x8FDB;&#x53BB;&#x7684;&#x51FD;&#x6570;&#x7684;&#x5143;&#x7D20;&#x3002;</li>
<li>&#x5982;&#x679C;&#x4F7F;&#x7528;&#x51FD;&#x6570;&#x65B9;&#x6CD5;&#xFF0C;&#x8FD9;&#x4E2A;&#x51FD;&#x6570;&#x5728;&#x88AB;&#x9009;&#x62E9;&#x7684;&#x5143;&#x7D20;&#x4E2D;&#x6267;&#x884C;&#xFF0C;&#x6240;&#x4EE5;this&#x6307;&#x5411;&#x7684;&#x624B;&#x52BF;&#x5F53;&#x524D;&#x5143;&#x7D20;&#x3002;</li>
</ul>
<pre><code class="lang-js">$(<span class="hljs-string">&apos;li&apos;</span>).filter(<span class="hljs-string">&apos;.orange&apos;</span>).attr(<span class="hljs-string">&apos;class&apos;</span>);<span class="hljs-comment">//=&gt; orange</span>

$(<span class="hljs-string">&apos;li&apos;</span>).filter(<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">i, el</span>) </span>{ 
    <span class="hljs-comment">// this === el </span>
    <span class="hljs-keyword">return</span> $(<span class="hljs-keyword">this</span>).attr(<span class="hljs-string">&apos;class&apos;</span>) === <span class="hljs-string">&apos;orange&apos;</span>;
}).attr(<span class="hljs-string">&apos;class&apos;</span>)&#xFF1B;


<span class="hljs-comment">//=&gt; orange</span>
</code></pre>
<h4 id="t363.2.28 append(content,[content&#x2026;])">3.2.28 append(content,[content&#x2026;]) <a href="#t363.2.28 append(content,[content&#x2026;])"> # </a></h4>
<p>&#x5728;&#x6BCF;&#x4E2A;&#x5143;&#x7D20;&#x6700;&#x540E;&#x63D2;&#x5165;&#x4E00;&#x4E2A;&#x5B50;&#x5143;&#x7D20;</p>
<pre><code class="lang-js">$(<span class="hljs-string">&apos;ul&apos;</span>).append(<span class="hljs-string">&apos;&lt;li class=&quot;plum&quot;&gt;Plum&lt;/li&gt;&apos;</span>)
$.html()
<span class="hljs-comment">//=&gt;</span>
<span class="hljs-comment">// &lt;li class=&quot;apple&quot;&gt;Apple&lt;/li&gt;</span>
<span class="hljs-comment">// &lt;li class=&quot;orange&quot;&gt;Orange&lt;/li&gt;</span>
<span class="hljs-comment">// &lt;li class=&quot;pear&quot;&gt;Pear&lt;/li&gt;</span>
<span class="hljs-comment">// &lt;li class=&quot;plum&quot;&gt;Plum&lt;/li&gt;//</span>
</code></pre>
<h4 id="t373.2.29 prepend(content,[content,&#x2026;])">3.2.29 prepend(content,[content,&#x2026;]) <a href="#t373.2.29 prepend(content,[content,&#x2026;])"> # </a></h4>
<p>&#x5728;&#x6BCF;&#x4E2A;&#x5143;&#x7D20;&#x6700;&#x524D;&#x63D2;&#x5165;&#x4E00;&#x4E2A;&#x5B50;&#x5143;&#x7D20;</p>
<pre><code class="lang-js">$(<span class="hljs-string">&apos;ul&apos;</span>).prepend(<span class="hljs-string">&apos;&lt;li class=&quot;plum&quot;&gt;Plum&lt;/li&gt;&apos;</span>)
$.html()
<span class="hljs-comment">//=&gt;</span>
<span class="hljs-comment">// &lt;li class=&quot;plum&quot;&gt;Plum&lt;/li&gt;</span>
<span class="hljs-comment">// &lt;li class=&quot;apple&quot;&gt;Apple&lt;/li&gt;</span>
<span class="hljs-comment">// &lt;li class=&quot;orange&quot;&gt;Orange&lt;/li&gt;</span>
<span class="hljs-comment">// &lt;li class=&quot;pear&quot;&gt;Pear&lt;/li&gt;</span>
</code></pre>
<h4 id="t383.2.30 after(content,[content,&#x2026;])">3.2.30 after(content,[content,&#x2026;]) <a href="#t383.2.30 after(content,[content,&#x2026;])"> # </a></h4>
<p>&#x5728;&#x6BCF;&#x4E2A;&#x5339;&#x914D;&#x5143;&#x7D20;&#x4E4B;&#x540E;&#x63D2;&#x5165;&#x4E00;&#x4E2A;&#x5143;&#x7D20;</p>
<pre><code class="lang-js">$(<span class="hljs-string">&apos;.apple&apos;</span>).after(<span class="hljs-string">&apos;&lt;li class=&quot;plum&quot;&gt;Plum&lt;/li&gt;&apos;</span>)
$.html()
<span class="hljs-comment">//=&gt;</span>
<span class="hljs-comment">// &lt;li class=&quot;apple&quot;&gt;Apple&lt;/li&gt;</span>
<span class="hljs-comment">// &lt;li class=&quot;plum&quot;&gt;Plum&lt;/li&gt;</span>
<span class="hljs-comment">// &lt;li class=&quot;orange&quot;&gt;Orange&lt;/li&gt;</span>
<span class="hljs-comment">// &lt;li class=&quot;pear&quot;&gt;Pear&lt;/li&gt;</span>
</code></pre>
<h4 id="t393.2.31 before(content,[content,&#x2026;])">3.2.31 before(content,[content,&#x2026;]) <a href="#t393.2.31 before(content,[content,&#x2026;])"> # </a></h4>
<p>&#x5728;&#x6BCF;&#x4E2A;&#x5339;&#x914D;&#x7684;&#x5143;&#x7D20;&#x4E4B;&#x524D;&#x63D2;&#x5165;&#x4E00;&#x4E2A;&#x5143;&#x7D20;</p>
<pre><code class="lang-js">$(<span class="hljs-string">&apos;.apple&apos;</span>).before(<span class="hljs-string">&apos;&lt;li class=&quot;plum&quot;&gt;Plum&lt;/li&gt;&apos;</span>)
$.html()
<span class="hljs-comment">//=&gt;</span>
<span class="hljs-comment">// &lt;li class=&quot;plum&quot;&gt;Plum&lt;/li&gt;</span>
<span class="hljs-comment">// &lt;li class=&quot;apple&quot;&gt;Apple&lt;/li&gt;</span>
<span class="hljs-comment">// &lt;li class=&quot;orange&quot;&gt;Orange&lt;/li&gt;</span>
<span class="hljs-comment">// &lt;li class=&quot;pear&quot;&gt;Pear&lt;/li&gt;</span>
</code></pre>
<h4 id="t403.2.32 remove( [selector] )">3.2.32 remove( [selector] ) <a href="#t403.2.32 remove( [selector] )"> # </a></h4>
<p>&#x4ECE;DOM&#x4E2D;&#x53BB;&#x9664;&#x5339;&#x914D;&#x7684;&#x5143;&#x7D20;&#x548C;&#x5B83;&#x4EEC;&#x7684;&#x5B50;&#x5143;&#x7D20;&#x3002;&#x9009;&#x62E9;&#x5668;&#x7528;&#x6765;&#x7B5B;&#x9009;&#x8981;&#x5220;&#x9664;&#x7684;&#x5143;&#x7D20;&#x3002;</p>
<pre><code class="lang-js">$(<span class="hljs-string">&apos;.pear&apos;</span>).remove()
$.html()<span class="hljs-comment">//=&gt;</span>

<span class="hljs-comment">// &lt;li class=&quot;apple&quot;&gt;Apple&lt;/li&gt;</span>
<span class="hljs-comment">// &lt;li class=&quot;orange&quot;&gt;Orange&lt;/li&gt;</span>
</code></pre>
<h4 id="t413.2.33 replaceWith( content )">3.2.33 replaceWith( content ) <a href="#t413.2.33 replaceWith( content )"> # </a></h4>
<p>&#x66FF;&#x6362;&#x5339;&#x914D;&#x7684;&#x7684;&#x5143;&#x7D20;</p>
<pre><code class="lang-js"><span class="hljs-keyword">var</span> plum = $(<span class="hljs-string">&apos;&lt;li class=&quot;plum&quot;&gt;Plum&lt;/li&gt;&apos;</span>)
$(<span class="hljs-string">&apos;.pear&apos;</span>).replaceWith(plum)
$.html()
<span class="hljs-comment">//=&gt;</span>
<span class="hljs-comment">// &lt;li class=&quot;apple&quot;&gt;Apple&lt;/li&gt;</span>
<span class="hljs-comment">// &lt;li class=&quot;orange&quot;&gt;Orange&lt;/li&gt;</span>
<span class="hljs-comment">// &lt;li class=&quot;plum&quot;&gt;Plum&lt;/li&gt;//</span>
</code></pre>
<h4 id="t423.2.34 empty()">3.2.34 empty() <a href="#t423.2.34 empty()"> # </a></h4>
<p>&#x6E05;&#x7A7A;&#x4E00;&#x4E2A;&#x5143;&#x7D20;&#xFF0C;&#x79FB;&#x9664;&#x6240;&#x6709;&#x7684;&#x5B50;&#x5143;&#x7D20;</p>
<pre><code class="lang-js">$(<span class="hljs-string">&apos;ul&apos;</span>).empty()$.html()
</code></pre>
<h4 id="t433.2.35 html( [htmlString] )">3.2.35 html( [htmlString] ) <a href="#t433.2.35 html( [htmlString] )"> # </a></h4>
<p>&#x83B7;&#x5F97;&#x5143;&#x7D20;&#x7684;HTML&#x5B57;&#x7B26;&#x4E32;&#x3002;&#x5982;&#x679C;htmlString&#x6709;&#x5185;&#x5BB9;&#x7684;&#x8BDD;&#xFF0C;&#x5C06;&#x4F1A;&#x66FF;&#x4EE3;&#x539F;&#x6765;&#x7684;HTML</p>
<pre><code class="lang-js">$(<span class="hljs-string">&apos;.orange&apos;</span>).html()
<span class="hljs-comment">//=&gt; Orange</span>
$(<span class="hljs-string">&apos;#fruits&apos;</span>).html(<span class="hljs-string">&apos;&lt;li class=&quot;mango&quot;&gt;Mango&lt;/li&gt;&apos;</span>).html()
<span class="hljs-comment">//=&gt; &lt;li class=&quot;mango&quot;&gt;Mango&lt;/li&gt;</span>
</code></pre>
<h4 id="t443.2.36 text( [textString] )">3.2.36 text( [textString] ) <a href="#t443.2.36 text( [textString] )"> # </a></h4>
<p>&#x83B7;&#x5F97;&#x5143;&#x7D20;&#x7684;text&#x5185;&#x5BB9;&#xFF0C;&#x5305;&#x62EC;&#x5B50;&#x5143;&#x7D20;&#x3002;&#x5982;&#x679C;textString&#x88AB;&#x6307;&#x5B9A;&#x7684;&#x8BDD;&#xFF0C;&#x6BCF;&#x4E2A;&#x5143;&#x7D20;&#x7684;text&#x5185;&#x5BB9;&#x90FD;&#x4F1A;&#x88AB;&#x66FF;&#x6362;&#x3002;</p>
<pre><code class="lang-js">$(<span class="hljs-string">&apos;.orange&apos;</span>).text()<span class="hljs-comment">//=&gt; Orange</span>
$(<span class="hljs-string">&apos;ul&apos;</span>).text()<span class="hljs-comment">//=&gt; Apple// Orange// Pear</span>
</code></pre>
<h3 id="t453.3 debug">3.3 debug <a href="#t453.3 debug"> # </a></h3>
<ul>
<li>&#x5728;&#x7F16;&#x5199;&#x7A0B;&#x5E8F;&#x7684;&#x65F6;&#x5019;&#xFF0C;&#x6709;&#x65F6;&#x5019;&#x9700;&#x8981;&#x8F93;&#x51FA;&#x4E00;&#x4E9B;&#x8C03;&#x8BD5;&#x4FE1;&#x606F;&#xFF0C;&#x4EE5;&#x4FBF;&#x6392;&#x67E5;&#x95EE;&#x9898;&#x3002;</li>
<li>&#x4F46;&#x662F;&#x5728;&#x7A0B;&#x5E8F;&#x8FD0;&#x884C;&#x8FC7;&#x7A0B;&#x4E2D;&#x53C8;&#x4E0D;&#x9700;&#x8981;&#x8FD9;&#x4E9B;&#x4FE1;&#x606F;&#xFF0C;&#x4E3A;&#x4E86;&#x65B9;&#x4FBF;&#x5207;&#x6362;&#x800C;&#x4E14;&#x4E0D;&#x9700;&#x8981;&#x6539;&#x4EE3;&#x7801;&#xFF0C;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;debug&#x6A21;&#x5757;<pre><code class="lang-js"><span class="hljs-keyword">let</span> debug = <span class="hljs-built_in">require</span>(<span class="hljs-string">&apos;debug&apos;</span>)(<span class="hljs-string">&apos;app:main&apos;</span>);
debug(<span class="hljs-string">&apos;&#x73B0;&#x5728;&#x7684;&#x65F6;&#x95F4;&#x662F;%s&apos;</span>,<span class="hljs-keyword">new</span> <span class="hljs-built_in">Date</span>());
</code></pre>
</li>
<li>Window&#x7CFB;&#x7EDF;&#x5728;&#x547D;&#x4EE4;&#x884C;&#x4E2D;&#x6267;&#x884C; <code>SET DEBUG=app:*</code></li>
<li>Mac&#x7CFB;&#x7EDF;&#x5728;&#x547D;&#x4EE4;&#x884C;&#x4E2D;&#x6267;&#x884C; <code>export DEBUG=app:*</code></li>
</ul>
<h3 id="t463.4 corn">3.4 corn <a href="#t463.4 corn"> # </a></h3>
<p><a href="https://www.npmjs.com/package/cron">cron</a>&#x7528;&#x6765;&#x5468;&#x671F;&#x6027;&#x7684;&#x6267;&#x884C;&#x67D0;&#x79CD;&#x4EFB;&#x52A1;&#x6216;&#x7B49;&#x5F85;&#x5904;&#x7406;&#x67D0;&#x4E9B;&#x4E8B;&#x4EF6;&#x7684;&#x4E00;&#x4E2A;&#x5B88;&#x62A4;&#x8FDB;&#x7A0B;</p>
<table>
<thead>
<tr>
<th style="text-align:left">&#x7B26;&#x53F7;</th>
<th style="text-align:left">&#x542B;&#x4E49;</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">&#x661F;&#x53F7;(*)</td>
<td style="text-align:left">&#x4EE3;&#x8868;&#x6240;&#x6709;&#x53EF;&#x80FD;&#x7684;&#x503C;</td>
</tr>
<tr>
<td style="text-align:left">&#x9017;&#x53F7;(,)</td>
<td style="text-align:left">&#x53EF;&#x4EE5;&#x7528;&#x9017;&#x53F7;&#x9694;&#x5F00;&#x7684;&#x503C;&#x6307;&#x5B9A;&#x4E00;&#x4E2A;&#x5217;&#x8868;&#x8303;&#x56F4;&#xFF0C;&#x4F8B;&#x5982;&#xFF0C;&#x201C;1,2,5,7,8,9&#x201D;</td>
</tr>
<tr>
<td style="text-align:left">&#x4E2D;&#x6760;(-)</td>
<td style="text-align:left">&#x53EF;&#x4EE5;&#x7528;&#x6574;&#x6570;&#x4E4B;&#x95F4;&#x7684;&#x4E2D;&#x6760;&#x8868;&#x793A;&#x4E00;&#x4E2A;&#x6574;&#x6570;&#x8303;&#x56F4;&#xFF0C;&#x4F8B;&#x5982;&#x201C;2-6&#x201D;&#x8868;&#x793A;&#x201C;2,3,4,5,6&#x201D;</td>
</tr>
<tr>
<td style="text-align:left">&#x6B63;&#x659C;&#x7EBF;(/)</td>
<td style="text-align:left">&#x53EF;&#x4EE5;&#x7528;&#x6B63;&#x659C;&#x7EBF;&#x6307;&#x5B9A;&#x65F6;&#x95F4;&#x7684;&#x95F4;&#x9694;&#x9891;&#x7387;&#xFF0C;*/10&#xFF0C;&#x5982;&#x679C;&#x7528;&#x5728;minute&#x5B57;&#x6BB5;&#xFF0C;&#x8868;&#x793A;&#x6BCF;&#x5341;&#x5206;&#x949F;&#x6267;&#x884C;&#x4E00;&#x6B21;</td>
</tr>
</tbody>
</table>
<table>
<thead>
<tr>
<th style="text-align:left">&#x5355;&#x4F4D;</th>
<th style="text-align:left">&#x8303;&#x56F4;</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">Seconds</td>
<td style="text-align:left">0-59</td>
</tr>
<tr>
<td style="text-align:left">Minutes</td>
<td style="text-align:left">0-59</td>
</tr>
<tr>
<td style="text-align:left">Hours</td>
<td style="text-align:left">0-23</td>
</tr>
<tr>
<td style="text-align:left">Day</td>
<td style="text-align:left">1-31</td>
</tr>
<tr>
<td style="text-align:left">Months</td>
<td style="text-align:left">0-11</td>
</tr>
<tr>
<td style="text-align:left">Day of Week</td>
<td style="text-align:left">0-6</td>
</tr>
</tbody>
</table>
<pre><code class="lang-js"><span class="hljs-keyword">var</span> cronJob = <span class="hljs-built_in">require</span>(<span class="hljs-string">&apos;cron&apos;</span>).CronJob;
<span class="hljs-keyword">var</span> job1 = <span class="hljs-keyword">new</span> cronJob(<span class="hljs-string">&quot;* * * * * *&quot;</span>,<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>)</span>{
  <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&apos;&#x6BCF;&#x79D2;&apos;</span>);
});
job1.start();
</code></pre>
<h3 id="t473.5 &#x76D1;&#x542C;&#x672A;&#x77E5;&#x9519;&#x8BEF;">3.5 &#x76D1;&#x542C;&#x672A;&#x77E5;&#x9519;&#x8BEF; <a href="#t473.5 &#x76D1;&#x542C;&#x672A;&#x77E5;&#x9519;&#x8BEF;"> # </a></h3>
<ul>
<li>&#x5927;&#x90E8;&#x5206;&#x60C5;&#x51B5;&#x4E0B;&#xFF0C;&#x5F02;&#x6B65;&#x7684;IO&#x64CD;&#x4F5C;&#x53D1;&#x751F;&#x7684;&#x9519;&#x8BEF;&#x65E0;&#x6CD5;&#x88AB;try catch&#x6355;&#x83B7;&#xFF0C;&#x5982;&#x679C;&#x6CA1;&#x6709;&#x6355;&#x83B7;&#x4F1A;&#x5BFC;&#x81F4;&#x7A0B;&#x5E8F;&#x9000;&#x51FA;</li>
<li>&#x5728;Node.js&#x4E2D;&#xFF0C;&#x5982;&#x679C;&#x4E00;&#x4E2A;&#x629B;&#x51FA;&#x7684;&#x5F02;&#x5E38;&#x6CA1;&#x6709;&#x88AB;try catch&#x6355;&#x83B7;&#xFF0C;&#x4F1A;&#x5C1D;&#x8BD5;&#x5C06;&#x9519;&#x8BEF;&#x4EA4;&#x7ED9;uncaughtException&#x4E8B;&#x4EF6;&#x5904;&#x7406;&#x51FD;&#x6570;&#x6765;&#x8FDB;&#x884C;&#x5904;&#x7406;&#xFF0C;&#x4EC5;&#x5F53;&#x6CA1;&#x6709;&#x6CE8;&#x518C;&#x8BE5;&#x4E8B;&#x4EF6;&#x5904;&#x7406;&#x51FD;&#x6570;&#x65F6;&#x624D;&#x4F1A;&#x5BFC;&#x81F4;&#x8FDB;&#x7A0B;&#x76F4;&#x63A5;&#x9000;&#x51FA;&#x3002;</li>
</ul>
<pre><code class="lang-js">process.on(<span class="hljs-string">&apos;uncaughtException&apos;</span>,<span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params">err</span>) </span>{
    <span class="hljs-built_in">console</span>.error(<span class="hljs-string">&apos;uncaughtException: %s&apos;</span>,erro.stack);
});
</code></pre>
<h3 id="t483.6 pm2">3.6 pm2 <a href="#t483.6 pm2"> # </a></h3>
<p>pm2&#x662F;&#x4E00;&#x4E2A;&#x529F;&#x80FD;&#x5F3A;&#x5927;&#x7684;&#x8FDB;&#x7A0B;&#x7BA1;&#x7406;&#x5668;&#xFF0C;&#x901A;&#x8FC7;<code>pm2 start</code>&#x6765;&#x542F;&#x52A8;&#x7A0B;&#x5E8F;, &#x5F53;&#x8BE5;&#x8FDB;&#x7A0B;&#x5F02;&#x5E38;&#x9000;&#x51FA;&#x65F6;,pm2&#x4F1A;&#x81EA;&#x52A8;&#x5C1D;&#x8BD5;&#x91CD;&#x542F;&#x8FDB;&#x7A0B;&#x3002;</p>
<pre><code class="lang-js">npm install pm2 -g
npm2 start 
pm2 stop 
</code></pre>
<h3 id="t493.7 &#x7F16;&#x7801;(iconv-lite)">3.7 &#x7F16;&#x7801;(iconv-lite) <a href="#t493.7 &#x7F16;&#x7801;(iconv-lite)"> # </a></h3>
<pre><code class="lang-js"><span class="hljs-keyword">var</span> request = <span class="hljs-built_in">require</span>(<span class="hljs-string">&apos;request&apos;</span>);
<span class="hljs-keyword">var</span> iconv=<span class="hljs-built_in">require</span>(<span class="hljs-string">&apos;iconv-lite&apos;</span>);
<span class="hljs-keyword">let</span> cheerio=<span class="hljs-built_in">require</span>(<span class="hljs-string">&apos;cheerio&apos;</span>);
request({<span class="hljs-attr">url</span>: <span class="hljs-string">&apos;http://top.baidu.com/buzz?b=26&amp;c=1&amp;fr=topcategory_c1&apos;</span>
, <span class="hljs-attr">encoding</span>: <span class="hljs-literal">null</span>},<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">err,response,body</span>)</span>{
    <span class="hljs-keyword">if</span>(err)
        <span class="hljs-built_in">console</span>.error(err);
    body = iconv.decode(body, <span class="hljs-string">&apos;gbk&apos;</span>).toString();
    <span class="hljs-keyword">let</span> $=cheerio.load(body);
    <span class="hljs-keyword">let</span> movies=[];
    $(<span class="hljs-string">&apos;.keyword .list-title&apos;</span>).each(<span class="hljs-function">(<span class="hljs-params">index,item</span>) =&gt;</span> {
        <span class="hljs-keyword">let</span> movie=$(item);
        movies.push({
            <span class="hljs-attr">name</span>:movie.text()
        });
    });
    <span class="hljs-built_in">console</span>.log(movies);
})
</code></pre>
<h3 id="t503.8 &#x53D1;&#x9001;&#x90AE;&#x4EF6;">3.8 &#x53D1;&#x9001;&#x90AE;&#x4EF6; <a href="#t503.8 &#x53D1;&#x9001;&#x90AE;&#x4EF6;"> # </a></h3>
<p><a href="https://nodemailer.com/about/">nodemailer</a>&#x662F;&#x4E00;&#x4E2A;&#x7B80;&#x5355;&#x6613;&#x7528;&#x7684;Node.js&#x90AE;&#x4EF6;&#x53D1;&#x9001;&#x6A21;&#x5757;</p>
<pre><code class="lang-js"><span class="hljs-keyword">const</span> nodemailer = <span class="hljs-built_in">require</span>(<span class="hljs-string">&apos;nodemailer&apos;</span>);
<span class="hljs-keyword">let</span> transporter = nodemailer.createTransport({
    <span class="hljs-comment">// host: &apos;smtp.ethereal.email&apos;,</span>
    service: <span class="hljs-string">&apos;qq&apos;</span>, <span class="hljs-comment">// &#x4F7F;&#x7528;&#x4E86;&#x5185;&#x7F6E;&#x4F20;&#x8F93;&#x53D1;&#x9001;&#x90AE;&#x4EF6; &#x67E5;&#x770B;&#x652F;&#x6301;&#x5217;&#x8868;&#xFF1A;https://nodemailer.com/smtp/well-known/</span>
    port: <span class="hljs-number">465</span>, <span class="hljs-comment">// SMTP &#x7AEF;&#x53E3;</span>
    secureConnection: <span class="hljs-literal">true</span>, <span class="hljs-comment">// &#x4F7F;&#x7528;&#x4E86; SSL</span>
    auth: {
        <span class="hljs-attr">user</span>: <span class="hljs-string">&apos;<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="b18982878986858180f1c0c09fd2dedc">[email&#160;protected]</a>&apos;</span>,
        <span class="hljs-comment">// &#x8FD9;&#x91CC;&#x5BC6;&#x7801;&#x4E0D;&#x662F;qq&#x5BC6;&#x7801;&#xFF0C;&#x662F;&#x4F60;&#x8BBE;&#x7F6E;&#x7684;smtp&#x6388;&#x6743;&#x7801;</span>
        pass: <span class="hljs-string">&apos;gfndwuvvfpbebjdi&apos;</span>,
    }
});

<span class="hljs-keyword">let</span> mailOptions = {
    <span class="hljs-attr">from</span>: <span class="hljs-string">&apos;&quot;83687401&quot; &lt;<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="29111a1f111e1d1918695858074a4644">[email&#160;protected]</a>&gt;&apos;</span>, <span class="hljs-comment">// sender address</span>
    to: <span class="hljs-string">&apos;<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="c3fbf0f5fbf4f7f3f283b2b2eda0acae">[email&#160;protected]</a>&apos;</span>, <span class="hljs-comment">// list of receivers</span>
    subject: <span class="hljs-string">&apos;hello&apos;</span>, <span class="hljs-comment">// Subject line</span>
    <span class="hljs-comment">// &#x53D1;&#x9001;text&#x6216;&#x8005;html&#x683C;&#x5F0F;</span>
    <span class="hljs-comment">// text: &apos;Hello world?&apos;, // plain text body</span>
    html: <span class="hljs-string">&apos;&lt;h1&gt;Hello world&lt;/h1&gt;&apos;</span> <span class="hljs-comment">// html body</span>
};

<span class="hljs-comment">// send mail with defined transport object</span>
transporter.sendMail(mailOptions, (error, info) =&gt; {
    <span class="hljs-keyword">if</span> (error) {
        <span class="hljs-keyword">return</span> <span class="hljs-built_in">console</span>.log(error);
    }
    <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&apos;Message sent: %s&apos;</span>, info.messageId);
    <span class="hljs-comment">// Message sent: &lt;<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="85b5b1e0e6b2b2b6b4a8e6e6b3bda8b4e0e3b3a8b6b5b6e6a8b3b4e7b5e3b2bcb3e7b2bde3c5f4f4abe6eae8">[email&#160;protected]</a>&gt;</span>
});
</code></pre>
<h2 id="t513.9 HTTP&#x4EE3;&#x7406;&#x5DE5;&#x5177;">3.9 HTTP&#x4EE3;&#x7406;&#x5DE5;&#x5177; <a href="#t513.9 HTTP&#x4EE3;&#x7406;&#x5DE5;&#x5177;"> # </a></h2>
<ul>
<li>Windows &#x5E73;&#x53F0;&#x6709; Fiddler&#xFF0C;macOS &#x6709; Charles&#xFF0C;&#x963F;&#x91CC;&#x6709;AnyProxy</li>
<li>&#x57FA;&#x672C;&#x539F;&#x7406;&#x5C31;&#x662F;&#x901A;&#x8FC7;&#x5728;&#x624B;&#x673A;&#x5BA2;&#x6237;&#x7AEF;&#x8BBE;&#x7F6E;&#x597D;&#x4EE3;&#x7406;IP&#x548C;&#x7AEF;&#x53E3;,&#x5BA2;&#x6237;&#x7AEF;&#x6240;&#x6709;&#x7684; HTTP&#x3001;HTTPS &#x8BF7;&#x6C42;&#x5C31;&#x4F1A;&#x7ECF;&#x8FC7;&#x4EE3;&#x7406;&#x5DE5;&#x5177;</li>
</ul>
<h3 id="t523.9.1 https&#x6293;&#x5305;&#x8BBE;&#x7F6E;">3.9.1 https&#x6293;&#x5305;&#x8BBE;&#x7F6E; <a href="#t523.9.1 https&#x6293;&#x5305;&#x8BBE;&#x7F6E;"> # </a></h3>
<h4 id="t533.9.1.1 Fiddler">3.9.1.1 Fiddler <a href="#t533.9.1.1 Fiddler"> # </a></h4>
<ul>
<li>Tools &gt; Fiddler Options &gt; Connections<ul>
<li>Fiddler listens on port 8888</li>
<li>Allow remote computers to connect</li>
</ul>
</li>
<li>Tools &gt; Fiddler Options &gt; HTTPS &gt; Decrypt HTTPS traffic<ul>
<li>Capture HTTPS CONNECTs</li>
<li>Decrypt HTTPS traffic</li>
</ul>
</li>
</ul>
<h4 id="t543.9.1.2 Android">3.9.1.2 Android <a href="#t543.9.1.2 Android"> # </a></h4>
<ul>
<li>&#x8FDB;&#x5165;&#x624B;&#x673A;&#x7684; WLAN &#x8BBE;&#x7F6E;&#xFF0C;&#x9009;&#x62E9;&#x5F53;&#x524D;&#x6240;&#x5728;&#x5C40;&#x57DF;&#x7F51;&#x7684; WiFi &#x94FE;&#x63A5;&#xFF0C;&#x8BBE;&#x7F6E;&#x4EE3;&#x7406;&#x670D;&#x52A1;&#x5668;&#x7684; IP &#x548C;&#x7AEF;&#x53E3;</li>
<li>&#x8BBF;&#x95EE;<a href="http://192.168.31.236:8888/&#x663E;&#x793A;echo&#x9875;&#x9762;">http://192.168.31.236:8888/&#x663E;&#x793A;echo&#x9875;&#x9762;</a></li>
<li>&#x4E0B;&#x8F7D; FiddlerRoot certificate&#xFF0C;&#x4E0B;&#x8F7D;&#x5E76;&#x5B89;&#x88C5;&#x8BC1;&#x4E66;&#xFF0C;&#x5E76;&#x9A8C;&#x8BC1;&#x901A;&#x8FC7;</li>
</ul>
<h4 id="t553.9.1.3 &#x6293;&#x53D6;&#x63A5;&#x53E3;">3.9.1.3 &#x6293;&#x53D6;&#x63A5;&#x53E3; <a href="#t553.9.1.3 &#x6293;&#x53D6;&#x63A5;&#x53E3;"> # </a></h4>
<ul>
<li>&#x8FC7;&#x6EE4; <code>mp.weixin.qq.com</code> &#x63A5;&#x53E3;</li>
<li>&#x5386;&#x53F2;&#x6D88;&#x606F; <a href="https://mp.weixin.qq.com/mp/profile_ext">https://mp.weixin.qq.com/mp/profile_ext</a></li>
<li>&#x6587;&#x7AE0;&#x8BE6;&#x60C5; <a href="https://mp.weixin.qq.com/mp/getappmsgext">https://mp.weixin.qq.com/mp/getappmsgext</a> </li>
</ul>
<h2 id="t56&#x53C2;&#x8003;">&#x53C2;&#x8003; <a href="#t56&#x53C2;&#x8003;"> # </a></h2>
<ul>
<li><a href="https://www.telerik.com/download/fiddler">fiddler</a></li>
<li><a href="https://www.cnblogs.com/joshua317/p/8670923.html">Fiddler&#x6293;&#x53D6;https&#x8BBE;&#x7F6E;&#x8BE6;&#x89E3;</a></li>
</ul>

        <div class="copyright">Powered by <a href="https://github.com/jaywcjlove/idoc" target="_blank">idoc</a>. Dependence <a href="https://nodejs.org">Node.js</a> run.</div>
    </div>
    
</div>

<script data-cfasync="false" src="/cdn-cgi/scripts/5c5dd728/cloudflare-static/email-decode.min.js"></script><script src="https://cdn.bootcss.com/jquery/3.0.0/jquery.js"></script>
<script>
$('.warpper .page-toc ul ul li a').on('click',function(){
  $('.warpper .page-toc ul ul li a').removeClass('my-active')
  $(this).addClass('my-active')
})
  // if (!$('.understand-me').length) {
  //   var bar = $(window).height() - $('.navbar ').height() - $('.page-toc').position().top;
  //   var count = bar / 26 / 2;
  //   var barHeight = $('.page-toc').outerHeight();
  //   $('.page-toc li').eq(0).children('a').addClass('red');
  //   var arr = [];
  //   $("h1,h2,h3,h4,h5,h6").each(function () {
  //     arr.push($(this).position().top);
  //   });
  //   var timer
  //   function dark() {
  //     clearTimeout(timer)
  //      timer = setTimeout(function () {
  //      var top = Math.abs($('.page-toc > ul').position().top);
  //      var cur = $('.content').scrollTop();
  //      for (var i = arr.length; i >= 0; i--) {
  //        if (arr[i] <= cur) {
  //          break;
  //        }
  //      }
  //      if (i === -1) {
  //        i = 0;
  //      }
  //      $('.page-toc li a').removeClass('red');
  //      $('.page-toc li').eq(i).children('a').addClass('red');
  //      let height = $('.page-toc li').eq(i).position().top-$('.page-toc').height(); // 如果当前的offset出去了 回到中间可好？
  //      $('.page-toc').scrollTop(height+$('.page-toc').height()/2);
  //    },200)
  //   }

  //   $('.content').on('scroll', dark);
  // }
</script>
<style>

    /* ::-webkit-scrollbar{width:14px;}
    ::-webkit-scrollbar-track{background-color:transparent;}
    ::-webkit-scrollbar-thumb{background-color:transparent;}
    ::-webkit-scrollbar-thumb:hover {background-color:transparent}
    ::-webkit-scrollbar-thumb:active {background-color:transparent} */

    .page-toc > ul .red {
        background: #f3f3f3;
        z-index: 1;
        border-left: 3px solid #009a61;
        -webkit-transition: all .2s ease;
        transition: all .2s ease;
        color: #000
    }





</style>
</body>
</html>
